#ifndef _TIMERFD_H_
#define _TIMERFD_H_

#include <functional>

using std::function;

namespace SearchEngine
{



class TimerFd
{
    using TimerFdCallback = function<void()>;

public:
    TimerFd(int initsec,int perisec,TimerFdCallback &&cb);
    ~TimerFd();
    void start();
    void stop();
private:
    void handleRead();
    int creatTimerFD();
    void setTimerFd(int initsec,int perisec);
private:
    int _timerfd;
    int _initsec;
    int _perisec;
    TimerFdCallback _cb;
    bool _isStarted;

};
}
#endif
